package com.lhwl.it.common.action;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.lhwl.it.common.service.CommonService;
import com.lhwl.it.util.RequestMap;
import com.lhwl.it.util.Xtcl;

@Controller
@RequestMapping("/itmanager/common")
public class CommonAction {
	private Log log=LogFactory.getLog(this.getClass());
	@Resource
	private CommonService commonService;
	
	@RequestMapping(value="/cllx",method=RequestMethod.GET)
	public String getCllx(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HashMap map=new RequestMap(request);
		String cllx=map.get("lx").toString();
		//map.put("cllx", cllx);
		List lx=Xtcl.getList(cllx);
//		List lx=this.commonService.list("CommonMapper.getCllx", map);
		JSONArray json=JSONArray.fromObject(lx);
		response.getWriter().print(json);
		return null;
	}
	
	@RequestMapping(value="/clid",method=RequestMethod.GET)
	public String getId(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HashMap map=new RequestMap(request);
		String clid=map.get("id").toString();
		//map.put("id", clid);
		HashMap m=(HashMap) Xtcl.getById(clid);
		//HashMap m=this.commonService.getMap("CommonMapper.getCllx", map);
		JSONObject json=JSONObject.fromObject(m);
		response.getWriter().print(json);
		return null;
	}
	
}
